package cn.gson.crm.control.source;

import java.util.List;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.control.base.BaseServlet;
import cn.gson.crm.model.dao.SourceDao;
import cn.gson.crm.model.entity.Source;

/**
 * Servlet implementation class SourceServlet
 */
@WebServlet("/source")
public class SourceServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
    private SourceDao sd=new SourceDao();
    
	@Override
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {	
		String p = request.getParameter("page");
		String sourceName = request.getParameter("sourceName");
		if (p == null || p.isEmpty()) {
			p = "1";
		}
		
		Integer page = Integer.parseInt(p);
		// 当前页数据
		List<Source> sourceNameList = sd.getPagepositionListByType(page, sourceName);
		// 总页数
		int totalPage = sd.getTotalPage(sourceName);
		request.setAttribute("queryString", noPageQueryString());
		request.setAttribute("sourceNameList", sourceNameList);
		request.setAttribute("totalPage", totalPage);
		request.setAttribute("page", page);
		forward("source/source.jsp");}
	

}
